﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;

namespace CB.Client
{
    /// <summary>
    /// 转场黑屏渐隐效果
    /// </summary>
    public class Transit : UIContent
    {
        public Animation Ani;

        public void ShowTransitAndAction(Action actDuring = null, Action actAfter = null)
        {
            ActionDuring = actDuring;
            ActionAfter = actAfter;
            GetComponent<Image>().color = new Color(0, 0, 0, 0);
            gameObject.SetActive(true);
            Ani.Play("Transit");
            Invoke("ActOnTransit", 0.67f);
        }

        Action ActionDuring = null;
        Action ActionAfter = null;
        void ActOnTransit()
        {
            ActionDuring?.Invoke();
            Invoke("Close", 0.73f);
        }
        void Close()
        {
            gameObject.SetActive(false);
            ActionAfter?.Invoke();
        }
    }
}